<!DOCTYPE html>

<html class="no-js"> 
<head>
	<meta charset="utf-8" />
	<title>Lenovo</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	
	<!-- BEGIN GLOBAL MANDATORY STYLES -->
	<link href="{{asset('media/css/bootstrap.min.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/bootstrap-responsive.min.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/font-awesome.min.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/style-metro.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/style.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/style-responsive.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/default.css')}}" rel="stylesheet" type="text/css" id="style_color"/>
	<link href="{{asset('media/css/uniform.default.css')}}" rel="stylesheet" type="text/css"/>
	<!-- END GLOBAL MANDATORY STYLES -->

	<!-- BEGIN PAGE LEVEL STYLES --> 
	<link href="{{asset('media/css/jquery.gritter.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/daterangepicker.css')}}" rel="stylesheet" type="text/css" />
	<link href="{{asset('media/css/fullcalendar.css')}}" rel="stylesheet" type="text/css"/>
	<link href="{{asset('media/css/jqvmap.css')}}" rel="stylesheet" type="text/css" media="screen"/>
	<link href="{{asset('media/css/jquery.easy-pie-chart.css')}}" rel="stylesheet" type="text/css" media="screen"/>
	<!-- END PAGE LEVEL STYLES -->

	<link rel="shortcut icon" href="{{asset('media/image/favicon.ico')}}" />
</head>

<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">

	<!-- BEGIN HEADER -->
	@include('admin.top')	
	<!-- END HEADER -->

	<!-- BEGIN CONTAINER -->
	<div class="page-container">

		<!-- BEGIN SIDEBAR -->
		<!--包含左侧公共文件-->
		@include('admin.left')
		<!-- END SIDEBAR -->
		<div class="row-fluid">
		<!-- BEGIN PAGE -->

		<div class="page-content">
			<div class="portlet box blue">
				<div class="portlet-title">
					<div class="caption"><i class="icon-edit"></i>用户列表</div>
					<div class="tools">
						<a href="javascript:;" class="collapse"></a>
						<a href="javascript:;" class="remove"></a>
					</div>
				</div>
				<div class="portlet-body">
                    <div class="span10">
                        <div class="inbox-header" style="margin-left:80px;margin-top:30px;">
                            <div class="btn-group">
                                <button id="sample_editable_1_new" class="btn green">
                                    <a style="text-decoration:none;color:white" href="/admin/user/add">
                                        添加用户 <i class="icon-plus"></i>
                                    </a>
                                </button>
                            </div>
                            <form action="/admin/user/search" class="form-search pull-right" method="get" style="margin-top:5px">
                                {!! csrf_field() !!}
                                <div class="input-append" style="margin-left: 100px">
                                    <input class="m-wrap" type="text" placeholder="请输入您要查询的相关信息" name="key">
                                    <button class="btn green" type="submit">Search</button>
                                </div>
                            </form>
                        </div>
                    </div>
					<style>
						.table th, .table td{ 
							text-align: center; 
							height:30px;
							line-height:30px;
						}
					</style>
					<table class="table table-striped table-hover table-bordered" id="sample_editable_1">
						<thead>
							<tr>
								<th>用户id</th>
								<th>用户名</th>
								<th>密码</th>
								<th>邮箱</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
                            @if($users->total())
                            @foreach($users as $user)
							<tr class="">
								<td>{{$user['uid']}}</td>
								<td>{{$user['uname']}}</td>
								<td>{{$user['upwd']}}</td>
								<td>{{$user['uemail']}}</td>
								<td align="center">
									<!-- 按钮触发模态框 -->
									<button data-id="{{$user['uid']}}" class="btn btn-primary btn-lg update" data-toggle="modal" data-target="#myModal">修改</button>
									<button data-id="{{$user['uid']}}" class="btn btn-primary btn-lg delete" >删除</button>
								</td>
							</tr>
                            @endforeach
                            @else
                                <tr><td colspan="5">没有查询到相关信息</td></tr>
                            @endif
						</tbody>
					</table>

                    <ul class="pagination" align="right" >
                        {!! $users->render() !!}
                    </ul>
				</div>
			</div>
			<!-- END EXAMPLE TABLE PORTLET-->

		</div>
			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
		</div>
		<!-- END PAGE -->
	</div>
	<!-- END CONTAINER -->

	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">修改用户信息</h4>
				</div>
				<div class="modal-body">
					 <form action="/admin/user/update" class="bs-example bs-example-form" role="form" method="post" style="margin-left:130px;">
					 {!! csrf_field() !!}
						<br>
						<div class="input-group">
							<span class="input-group-addon">用户ID: </span>
							<input type="text" class="form-control" placeholder="" readonly name="uid">
						</div>
						<br>
						<div class="input-group">
							<span class="input-group-addon">用户名: </span>
							<input type="text" class="form-control" placeholder="" name="uname">
						</div>
						<br>
						<div class="input-group">
							<span class="input-group-addon">密码:&nbsp; </span>
							<input type="password" class="form-control" placeholder="" name="upwd">
						</div>
						<br>
						<div class="input-group">
							<span class="input-group-addon">邮箱:&nbsp; </span>
							<input type="email" class="form-control" placeholder="" name="uemail">
						</div>
                         <br>
                         <div style="margin-left:200px;">
                             <button type="submit" class="btn btn-primary">提交更改</button>&nbsp;
                             <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                         </div>
					</form>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->

	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->

	<!-- BEGIN CORE PLUGINS -->
	<script src="{{asset('media/js/jquery-1.10.1.min.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery-migrate-1.2.1.min.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery-ui-1.10.1.custom.min.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/bootstrap.min.js')}}" type="text/javascript"></script> 
	<script src="{{asset('media/js/jquery.slimscroll.min.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery.blockui.min.js')}}" type="text/javascript"></script>  
	<script src="{{asset('media/js/jquery.cookie.min.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery.uniform.min.js')}}" type="text/javascript" ></script>
	<!-- END CORE PLUGINS -->

	<!-- BEGIN PAGE LEVEL PLUGINS -->  
	<script src="{{asset('media/js/jquery.flot.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery.flot.resize.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery.pulsate.min.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/date.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/daterangepicker.js')}}" type="text/javascript"></script>     
	<script src="{{asset('media/js/jquery.gritter.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/fullcalendar.min.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery.easy-pie-chart.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/jquery.sparkline.min.js')}}" type="text/javascript"></script>  
	<!-- END PAGE LEVEL PLUGINS -->

	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="{{asset('media/js/app.js')}}" type="text/javascript"></script>
	<script src="{{asset('media/js/index.js')}}" type="text/javascript"></script>        
	<!-- END PAGE LEVEL SCRIPTS -->  
	
	<script>
		jQuery(document).ready(function() {    
		   App.init(); // initlayout and core plugins
		   Index.init();
		   Index.initJQVMAP(); // init index page's custom scripts
		   Index.initCalendar(); // init index page's custom scripts
		   Index.initCharts(); // init index page's custom scripts
		   Index.initChat();
		   Index.initMiniCharts();
		   Index.initDashboardDaterange();
		   Index.initIntro();
		});
	</script>
	<!-- END JAVASCRIPTS -->
    <script>
        $(function(){
            $('.delete').bind('click',function(){
                //获取删除用户的id
                var uid=$(this).attr('data-id');
                //确定用户操作
                if(!confirm('你确定你要删除id为:'+uid+'的用户吗?')){
                    return false;
                }
                var $btn=$(this);
                //ajax传送到服务器
                $.ajax({
                    url:'/admin/user/delete',
                    data:'uid='+uid,
                    type:'get',
                    dataType:'text',
                    success:function(data){
                        //根据返回信息判断是否删除成功
                        if(data == 1){
                            $btn.parents('tr').remove();
                        }else{
                            alert('删除失败');
                        }
                    }
                })
            });

            $('.update').bind('click',function(){
               var uid=$(this).attr('data-id');
                $.ajax({
                    url:'/admin/user/modify',
                    data:'uid='+uid,
                    type:'get',
                    dataType:'json',
                    success:function(data){
                        //将用户信息放入到弹出框中
                        $('input[name="uid"]').val(data.uid);
                        $('input[name="uname"]').val(data.uname);
                        $('input[name="uemail"]').val(data.uemail);
                    }
                });
            });
        });

    </script>
</body>
<!-- END BODY -->
</html>